//
//  CTTableView.swift
//  CodingTest
//
//  Created by LYPC on 2021/11/18.
//

import UIKit
import MJRefresh
import SnapKit

open class CTTableView: UITableView, ScrollViewAnimateProtocol {
    
    override public init(frame: CGRect, style: UITableView.Style) {
        super.init(frame: frame, style: style)
        
        self.backgroundColor = UIColor.white
        self.showsHorizontalScrollIndicator = false
        self.showsVerticalScrollIndicator = false
        self.estimatedSectionHeaderHeight = 0
        self.estimatedSectionFooterHeight = 0
        self.estimatedRowHeight = 0
        self.separatorStyle = .none
        self.tableFooterView = UIView()
    }
    
    @available(*, unavailable, message: "Loading this view from a nib is unsupported")
    public required init?(coder aDecoder: NSCoder) {
        fatalError("Loading this view from a nib is unsupported")
    }
    
    public lazy var animateView: UIActivityIndicatorView = {
        let indicator = UIActivityIndicatorView()
        if #available(iOS 13.0, *) {
            indicator.style = .medium
        } else {
            indicator.style = .white
        }
        indicator.color = .gray
        self.addSubview(indicator)
        indicator.snp.makeConstraints({ (m) in
            m.centerX.equalToSuperview()
            m.centerY.equalToSuperview().offset(-50.fitC)
        })
        return indicator
    }()
    
    public var baseView: UIScrollView {
        return self
    }
    
    deinit {
        k_logViewDeinit(self)
    }
}
